/*
 * @Author: shiguo
 * @Date: 2022-04-18 14:32:25
 * @LastEditors: shiguo
 * @LastEditTime: 2022-09-09 10:35:02
 * @FilePath: /@aks-dev/easyui/screen/px2dp.ts
 */
import { Dimensions, Platform, StatusBar } from 'react-native';


// 设备宽度，单位 dp
export const deviceWidth = Dimensions.get('screen').width;      //设备的宽度
export const deviceHeight = Dimensions.get('screen').height;    //设备的高度
export const isAndroid = Platform.OS === "android"
export const isIos = Platform.OS === 'ios'
export const isiPhoneX = isIos && (deviceHeight > 736)

/** 
 * 375px/667px 
 * */
const uiWidthPx = 375;



// const pixelRatio = PixelRatio.get()
// const deviceWidthPx = PixelRatio.getPixelSizeForLayoutSize(deviceWidth);



export const px2dp = (uiElePx: number) => {
    return Math.round(uiElePx * deviceWidth / uiWidthPx);
}





export const statusBarHeight = (() => {
    if (isAndroid) return StatusBar.currentHeight || 24
    if (isiPhoneX) return 44
    return 20
})()



export const navigationBarHeight = ( () => {
    if (isAndroid) return 56
    return 44
})()


